//机构与部门
import request from "@/api/request.js";

export const getAllInstitutionService = () => {
  //admin_panel/institutions
  return request.get("/api-self/admin_panel/institutions");
};

export const addInstitutionService = DataObj => {
  return request.post("/api-self/admin_panel/institution", DataObj);
};

export const delInstitutionService = institutionId => {
  let url = `/api-self/admin_panel/institution/${institutionId}`;
  return request.delete(url);
};

export const editInstitutionService = DataObj => {
  let Data = {
    institutionName: DataObj.institutionName,
    description: DataObj.description
  };
  let url = `/api-self/admin_panel/institution/${DataObj.institutionId}`;
  return request.put(url, Data);
};

export const getInstutitionService = institutionId => {
  return request.get(`/api-self/admin_panel/institution/${institutionId}`);
};

export const getDepsService = institutionid => {
  let url = `/api-self/admin_panel/institution/${institutionid}/departments`;
  return request.get(url);
};

export const addDepService = DataObj => {
  let url = `/api-self/admin_panel/institution/${DataObj.institutionId}/department`;
  let Data = {
    departmentName: DataObj.departmentName,
    description: DataObj.description,
    institutionId: DataObj.institutionId
  };
  return request.post(url, Data);
};

export const delDepService = DataObj => {
  let url = `/api-self/admin_panel/institution/${DataObj.institutionId}/department/${DataObj.departmentId}`;
  return request.delete(url);
};

export const editDepService = DataObj => {
  let url = `/api-self/admin_panel/institution/${DataObj.institutionId}/department/${DataObj.departmentId}`;
  let Data = {
    departmentName: DataObj.departmentName,
    description: DataObj.description,
    institutionId: DataObj.institutionId,
    departmentId: DataObj.departmentId
  };
  return request.delete(url, Data);
};

export const getDepService = DataObj => {
  let url = `/api-self/admin_panel/institution/${DataObj.institutionId}/department/${DataObj.departmentId}`;
  return request.get(url);
};
